#include <iostream>

using namespace std;

const int N = 1e5 + 10;
int n, m;
int f[N];
int pf[N];

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		cin >> pf[i];
	}
	
	for(int i = 1; i < m; i++)
	{
		int x = pf[i], y = pf[i + 1];
		if(x > y) swap(x, y);
		f[x]++; f[y]--;
	}
	
	for(int i = 1; i < n; i++) f[i] = f[i - 1] + f[i];
	
	long long ans = 0;
	for(int i = 1; i < n; i++)
	{
		long long a, b, c; cin >> a >> b >> c;
		long long cost1 = a * f[i];
		long long cost2 = c + b * f[i];
		ans += min(cost1, cost2);
	}
	
	cout << ans << endl;
	
	return 0;
} 
